<template>
  <span class="item-group">
    <el-button v-clickForbidden icon="el-icon-search" size="middle" @click="handleQuery">搜索</el-button>
    <el-button v-clickForbidden icon="el-icon-refresh" size="middle" @click="resetQuery">重置</el-button>
    <el-button v-hasPermi="[`system:${hasPermi}:add`]" icon="el-icon-plus" size="middle" @click="handleAdd">新增</el-button>
    <el-button v-hasPermi="[`system:${hasPermi}:edit`]" icon="el-icon-edit" size="middle" :disabled="single" @click="handleUpdate">修改</el-button>
    <el-button v-hasPermi="[`system:${hasPermi}:remove`]" icon="el-icon-delete" size="middle" :disabled="single" @click="handleDelete">删除</el-button>
  </span>
</template>

<script>
export default {
  name: 'Index',
  props: {
    single: {
      type: Boolean,
      default() {
        return true
      }
    },
    hasPermi: {
      type: String,
      default() {
        return ''
      }
    },
    isParent: {
      type: Boolean,
      default() {
        return false
      }
    }
  },
  data() {
    return {

    }
  },
  methods: {
    // 搜索
    handleQuery() {
      if (this.isParent) return this.$parent.$parent.$parent.handleQuery()

      this.$parent.handleQuery()
    },
    // 重置
    resetQuery() {
      this.$parent.resetQuery()
    },
    // 新增
    handleAdd() {
      this.$parent.handleAdd()
    },
    // 修改
    handleUpdate() {
      this.$parent.handleUpdate()
    },
    // 删除
    handleDelete() {
      this.$parent.handleDelete()
    }
  }
}
</script>

